<template>
  <div>
    <div v-if="companyInfoIndustry.company_id">
      <div v-if="detailType">
        <div class="title">原告裁决文书：{{ companyInfoIndustry.property_dispute.count }}</div>
        <div class="table" v-if="!PdfType">
          <el-table :data="companyInfoIndustry.property_dispute.list" border style="width: 100%"
            :header-cell-style="{ background: '#f0f7fc' }">
            <el-table-column prop="crd" label="立案年">
              <template slot-scope="scope">
                {{ scope.row.crd | time }}
              </template>
            </el-table-column>
            <el-table-column prop="ccto" label="案件名称"> </el-table-column>
            <el-table-column prop="cro" label="案由"> </el-table-column>
            <el-table-column prop="ct" label="案件类型"> </el-table-column>
            <el-table-column align="center" width="120" label="操作">
              <template slot-scope="scope">
                <el-button class="see" @click="see(scope.row.cid)" type="text">查看</el-button>

                <el-button class="see" @click="openUrl(scope.row.cid)" type="text">下载</el-button>
              </template>
            </el-table-column>
          </el-table>

          <div class="more" @click="moreAdd(4, 1)">查看全部</div>
        </div>
        <div v-else>
          <table border="1" v-if="companyInfoIndustry.property_dispute.list.length">
            <tr class="tableTr">
              <th class="tableTh" align="center">序号</th>
              <th class="tableTh" align="center">立案年</th>
              <th class="tableTh" align="center">案件名称</th>
              <th class="tableTh" align="center">案由</th>
              <th class="tableTh" align="center">案件类型</th>
            </tr>
            <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.property_dispute.list"
              :key="'companyInfoIndustry.property_dispute.list' + index">
              <td class="tableTd" align="center">{{ index + 1 }}</td>
              <td class="tableTd" align="center">
                {{ item.crd | time }}
              </td>
              <td class="tableTd" align="center">{{ item.ccto }}</td>
              <td class="tableTd" align="center">{{ item.cro }}</td>
              <td class="tableTd" align="center">{{ item.ct }}</td>
            </tr>
          </table>
          <div v-else class="legendText">暂无数据</div>
          <div v-if="companyInfoIndustry.property_dispute.list.length > 10 && PdfType" style="margin-top: 5px;">
            **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）
          </div>
        </div>
      </div>
      <div v-else>
        <div v-if="data" class="content">
          <el-button @click="back" size="mini" type="danger">返回</el-button>
          <p v-html="data" style="margin-top: 10px"></p>
        </div>
        <div v-else>
          <el-button @click="back" size="mini" type="danger">返回</el-button>
          <el-empty description="暂无信息"></el-empty>
        </div>
      </div>
    </div>
    <div v-if="companyInfoIndustry.company_id && companyInfoIndustry.property_dispute_two">
      <div v-if="detailType">
        <div class="title">被告裁决文书：{{ companyInfoIndustry.property_dispute_two.count }}</div>
        <div class="table" v-if="!PdfType">
          <el-table :data="companyInfoIndustry.property_dispute_two.list" border style="width: 100%"
            :header-cell-style="{ background: '#f0f7fc' }">
            <el-table-column prop="crd" label="立案年">
              <template slot-scope="scope">
                {{ scope.row.crd | time }}
              </template>
            </el-table-column>
            <el-table-column prop="ccto" label="案件名称"> </el-table-column>
            <el-table-column prop="cro" label="案由"> </el-table-column>
            <el-table-column prop="ct" label="案件类型"> </el-table-column>
            <el-table-column align="center" width="120" label="操作">
              <template slot-scope="scope">
                <el-button class="see" @click="see(scope.row.cid)" type="text">查看</el-button>

                <el-button class="see" @click="openUrl(scope.row.cid)" type="text">下载</el-button>
              </template>
            </el-table-column>
          </el-table>

          <div class="more" @click="moreAdd(4, 2)">查看全部</div>
        </div>
        <div v-else>
          <table border="1" v-if="companyInfoIndustry.property_dispute_two.list.length">
            <tr class="tableTr">
              <th class="tableTh" align="center">序号</th>
              <th class="tableTh" align="center">立案年</th>
              <th class="tableTh" align="center">案件名称</th>
              <th class="tableTh" align="center">案由</th>
              <th class="tableTh" align="center">案件类型</th>
            </tr>
            <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.property_dispute_two.list"
              :key="'companyInfoIndustry.property_dispute_two.list' + index">
              <td class="tableTd" align="center">{{ index + 1 }}</td>
              <td class="tableTd" align="center">
                {{ item.crd | time }}
              </td>
              <td class="tableTd" align="center">{{ item.ccto }}</td>
              <td class="tableTd" align="center">{{ item.cro }}</td>
              <td class="tableTd" align="center">{{ item.ct }}</td>
            </tr>
          </table>
          <div v-else class="legendText">暂无数据</div>
          <div v-if="companyInfoIndustry.property_dispute_two.list.length > 10 && PdfType" style="margin-top: 5px;">
            **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）
          </div>
        </div>
      </div>
      <div v-else>
        <div v-if="data" class="content">
          <el-button @click="back" size="mini" type="danger">返回</el-button>
          <p v-html="data" style="margin-top: 10px"></p>
        </div>
        <div v-else>
          <el-button @click="back" size="mini" type="danger">返回</el-button>
          <el-empty description="暂无信息"></el-empty>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      data: "",
      detailType: true,
    };
  },
  watch: {
    companyInfoIndustry: {
      handler(newVal, oldVal) { },
      deep: true,
    },
  },
  filters: {
    time(date) {
      return date.slice(0, 10);
    },
  },
  props: {
    PdfType: {
      type: Boolean,
      default: false,
    },
    companyInfoIndustry: {
      type: Object,
      default: () => { },
    },
  },
  components: {},
  mounted() { },
  methods: {
    back() {
      this.detailType = true;
      this.data = "";
    },
    async see(cid) {
      // this.detailType = false;
      try {
        // axios.defaults.baseURL = "https://patent.shundeip.com";
        // axios({
        //   method: "post",
        //   url: "/v1/frontend/Iitigation/detail",
        //   data: {
        //     cid: cid,
        //   },
        //   headers: {
        //     Authorization: "3bcbcf93da59f3e0c95e0c3d90f11112-0",
        //     post: {
        //       "Content-Type": "application/json",
        //     },
        //   },
        // }).then((res) => {
        //   this.data = res.data.data.html;
        // });

        let routerJump;
        routerJump = this.$router.resolve({
          path: "/morePatents",
          query: {
            patentType: 9,
            cid: cid,
          },
        });
        window.open(routerJump.href, "_blank");

      } catch (e) {
        this.$message.error(e.message);
      }
    },
    async openUrl(id) {
      try {
        axios.defaults.baseURL = "https://patent.shundeip.com";
        axios({
          method: "post",
          url: "/v1/frontend/iitigation/download",
          data: {
            cid: id,
          },
          headers: {
            Authorization: "3bcbcf93da59f3e0c95e0c3d90f11112-0",
            post: {
              "Content-Type": "application/json",
            },
          },
        }).then((res) => {
          window.open(res.data.data.pdf);
        });
      } catch (error) {
        this.$message.error(error.message);
      }
    },
    moreAdd(type, expressType) {
      // this.$router.push({
      //   path: "/morePatents",
      //   query: {
      //     patentType: type,
      //     company_id: this.companyInfoIndustry.company_id,
      //   },
      // });

      let routerJump = this.$router.resolve({
        path: "/morePatents",
        query: {
          expressType: expressType,
          patentType: type,
          companyName: this.companyInfoIndustry.company,
          company_id: this.companyInfoIndustry.company_id,
        },
      });
      window.open(routerJump.href, "_blank");
    },
  },
};
</script>

<style scoped lang="less">
.more {
  text-align: center;
  padding: 20px;
  border-bottom: 1px solid #ebeef5;
  cursor: pointer;
}

.title {
  font-size: 18px;
  font-weight: bold;
}

.table {
  padding: 20px 0px;
}

.institutionName {
  margin: 30px 0 20px 0;
  font-size: 14px;
}

.newinstitutionName {
  margin: 40px 0;
  font-size: 14px;

  div {
    margin-bottom: 10px;
    line-height: 20px;

    span {
      background-color: #ff5f59;
      border-radius: 2px;
      color: #fff;
      font-size: 11px;
      padding: 0px 3px;
      margin-left: 5px;
      box-sizing: border-box;
      display: inline-block;
    }
  }
}

.PatentType {
  display: flex;

  .item {
    background-color: #f2f3f5;
    border-radius: 10px;
    border: 1px solid #3677f5;
    padding: 20px 0;
    width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    margin-right: 30px;
    cursor: pointer;

    .value {
      color: #3677f5;
      font-size: 16px;
      margin-bottom: 4px;
    }

    .number {
      font-size: 30px;
    }
  }

  .item2 {
    background-color: #3677f5;

    .value {
      color: #fff;
    }

    .number {
      color: #fff;
    }
  }
}

.echartsBox {
  width: 100%;
  height: 100%;
}

.echarts {
  padding: 20px 0px;
  display: flex;

  .left {
    width: 100px;

    .activation {
      color: #006cff;
    }

    div {
      margin-bottom: 10px;
      cursor: pointer;
    }
  }

  .right {
    flex: 1;
  }
}

@media (max-width: 1360px) {}

@media (max-width: 1280px) {}

@media (max-width: 768px) {}
</style>
